﻿using Infrastructure;
using OpenAuth.Domain;
using OpenAuth.Domain.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenAuth.App
{
    /// <summary>
    /// ⑥应用层内，组合仓储接口，定义表现层需要的公共方法，调用领域服务
    /// 需要先在领域层定义领域服务，其实只是简化了一下调用关系
    /// </summary>
    public class SortDetailManagerApp
    {
        private SortDetailManagerService _sortDetailManagerService;
        public SortDetailManagerApp(SortDetailManagerService sortDetailManagerService)
        {
            _sortDetailManagerService = sortDetailManagerService;
        }

        public int GetSortDetailCntInOrg(Guid orgId)
        {
            return _sortDetailManagerService.GetSortDetailCntInOrg(orgId);
        }

        public List<SortDetail> LoadAll()
        {
            return _sortDetailManagerService.LoadAll();
        }

        /// <summary>
        /// 加载一个节点下面的一个或全部SortDetails
        /// </summary>
        public dynamic Load(string username, Guid sortId, int pageindex, int pagesize)
        {
            return _sortDetailManagerService.Load(username, sortId, pageindex, pagesize);
        }



        public void Delete(Guid[] ids)
        {
            _sortDetailManagerService.Delete(ids);
        }

        public void AddOrUpdate(SortDetail model)
        {
            SortDetail SortDetail = new SortDetail();
            model.CopyTo(SortDetail);
            _sortDetailManagerService.AddOrUpdate(SortDetail);

        }

        /// <summary>
        /// 获取带有授权状态的菜单列表
        /// </summary>
        /// <param name="accessType">授权类型，当前有RoleSortDetail/UserSortDetail</param>
        /// <param name="firstId">
        /// 当为RoleSortDetail时，表示RoleId
        /// 当为UserSortDetail时，表示UserId
        /// </param>
        /// <param name="cId">分类ID</param>
        public List<dynamic> LoadWithAccess(string username, string accessType, Guid firstId, Guid cId)
        {
            return _sortDetailManagerService.LoadWithAccess(username, accessType, firstId, cId);
        }


    }
}
